How to change the upload path in CKFinder?

by lily.simonis , in category: JavaScript , a year ago

How to change the upload path in CKFinder?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by mazie_pollich , a year ago

@lily.simonis 

CKFinder is a popular file manager and uploader plugin for web applications. By default, CKFinder uploads files to a specific directory within the installation folder. However, you can change the upload path to a different location using the configuration options available in CKFinder.


Here are the steps to change the upload path in CKFinder:

  1. Locate the CKFinder configuration file named config.php. It is usually located in the ckfinder folder within your web application directory.
  2. Open the config.php file in a text editor.
  3. Find the baseDir option in the configuration file. This option specifies the base directory where the uploaded files will be stored.
  4. Update the value of baseDir to the desired upload path. For example, if you want to store uploaded files in a folder named uploads in the root directory of your web application, you can set the value of baseDir as follows:
1
'baseDir' => '/uploads/',


  1. Save the changes to the config.php file.
  2. Test the new upload path by uploading a file using CKFinder.


Note that the new upload path must be a valid directory path that is accessible to the web server. Make sure to set appropriate permissions for the new upload directory to ensure that CKFinder can write files to it.

by cruz.howell , 3 months ago

@lily.simonis 

Additionally, you can also create dynamic upload paths by using tokens in the configuration file. For example, you can include the current date or user ID in the upload path.


Here's how you can use tokens in CKFinder to create dynamic upload paths:

  1. Open the config.php file in a text editor.
  2. Find the baseDir option in the configuration file.
  3. Update the value of baseDir to include tokens using the {token_name} syntax. For example:


'baseDir' => '/uploads/{date}_{userid}/',


In this example, {date} and {userid} are tokens that will be replaced with the current date and user ID.

  1. Save the changes to the config.php file.
  2. Test the new upload path by uploading a file using CKFinder.


CKFinder provides various tokens that you can use to create dynamic upload paths. Some of the commonly used tokens include {date}, {time}, {rand}, {filename}, {extension}, {username}, and {userid}. You can refer to the CKFinder documentation for a complete list of available tokens.


Using dynamic upload paths can help you organize uploaded files based on certain criteria, making it easier to manage and retrieve files later on.